package com.privatework.backedserver.controller.classroom;

import com.privatework.common.requestvo.classroom.ClassRoomReqVo;
import com.privatework.common.requestvo.leave.LeaveInfoReqVo;
import com.privatework.common.service.classroom.ClassRoomService;
import com.privatework.common.service.leave.LeaveService;
import com.privatework.common.utils.PageUtil;
import com.privatework.common.utils.ResultVoUtil;
import com.privatework.common.vo.PageVo;
import com.privatework.common.vo.ResultVo;
import com.privatework.common.vo.classroom.ClassRoomHistoryResultVo;
import com.privatework.common.vo.classroom.ClassRoomResultVo;
import com.privatework.common.vo.leave.LeaveInfoResultVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

/**
 * 用户 Controller
 *
 * @author johnny
 * @create 2020-07-10 下午4:08
 **/
@RestController
@Slf4j
@RequestMapping("/classroom")
public class ClassRoomController {

    @Autowired
    private ClassRoomService classRoomService;


    @GetMapping("/listByCondition")
    public ResultVo listByCondition(ClassRoomReqVo classRoomReqVo, PageVo pageVo) {
        pageVo.setPageNumber(pageVo.getPageNumber() - 1);
        Page<ClassRoomResultVo> page = classRoomService.listByCondition(classRoomReqVo, PageUtil.initPage(pageVo));
        return ResultVoUtil.success(page);
    }

    @GetMapping("/listHistoryByCondition")
    public ResultVo listHistoryByCondition(ClassRoomReqVo classRoomReqVo,PageVo pageVo) {
        pageVo.setPageNumber(pageVo.getPageNumber() - 1);
        Page<ClassRoomHistoryResultVo> page = classRoomService.listHistoryByCondition(classRoomReqVo,PageUtil.initPage(pageVo));
        return ResultVoUtil.success(page);
    }


    @PostMapping("/submitClassRoomUseInfo")
    public ResultVo submitClassRoomUseInfo(@RequestBody ClassRoomReqVo classRoomReqVo) {
        log.info("【classRoomReqVo ： {}】  ", classRoomReqVo);
        classRoomService.submitClassRoomUseInfo(classRoomReqVo);
        return ResultVoUtil.success();
    }


//
//    @PostMapping("/submitaddLeave")
//    public ResultVo submitaddLeave(@RequestBody LeaveInfoReqVo leaveInfoReqVo) {
//        log.info("【leaveInfoReqVo ： {}】  ", leaveInfoReqVo);
//        leaveService.submitaddLeave(leaveInfoReqVo);
//        return ResultVoUtil.success();
//    }


}